from test_cases import gua_dicts
from core.LiuYao import LiuYaoPlace
from core.engine.HexMatxOperator import HexagramMatrixOperator

clauses = [
    ['化进', '化退', '回头克', '空亡', '!空亡', '月和3', '日差6'],
    ['回头克', '回头生'],
    ['动爻克', '动爻生'],
    ['化差1', '化和3', '化合', '伏吟'],
    ['动爻冲', '动爻合']
]


def judge1(gua_dict, clause):
    operator = HexagramMatrixOperator(gua_dict)
    LiuYaoPlace(operator.dynamic_layer.tensor.gua).place(is_contain_gan=True, output=True)  # 如有必要，打印卦文
    operator.print_info(clause)
    return operator.judge(clause)


def judge_from_gua_data(gua_dict, clauses, is_plain=False):
    '''提供一个简洁的接口。不必局限于这个实例函数，你可以创建若干实例，并且提供若干 clause 用来大量判断正误。'''
    operator = HexagramMatrixOperator(gua_dict)
    # print(operator.dynamic_layer.tensor.zhi)  # 如有必要，查看原始张量
    LiuYaoPlace(operator.dynamic_layer.tensor.gua).place(is_contain_gan=True, output=True)  # 如有必要，打印卦文

    result = []
    for clause in clauses:
        operator.print_info(clause)  # 如有必要，查看二进制矩阵
        result.append(operator.judge(clause, is_plain))
    return result


if __name__ == '__main__':
    # print(judge_from_gua_data(gua_dicts[1],clauses[0]))

    # print(judge_from_gua_data(gua_dicts[1],clauses_[-1]))
    print(judge_from_gua_data(gua_dicts[3], clauses[-4]))
